﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MostCommon1
{
    class Program
    {
        static string mostCommonString(string[] array )
        {
            SortedDictionary<string, int> names = new SortedDictionary<string, int>();

            int currentMinOccurances = 0;
            string currentString = "";
            for (int index = 0; index < array.Length; index++)
            {
                int count;
                if (!names.TryGetValue(array[index], out count))
                {
                    count = 0;
                }
                names[array[index]] = ++count ;
                if (currentMinOccurances < count)
                {
                    currentMinOccurances = count;
                    currentString = array[index];
                }
                else if (currentMinOccurances == count)
                {
                    if (currentString.CompareTo( array[index]) == 1)
                    {
                        currentString = array[index];
                    }
                }


            }
            
            //foreach (var item in names)
            //{
            //    if (item.Value > currentMinOccurances)
            //    {
            //        currentMinOccurances = item.Value;
            //        currentString = item.Key;
            //    }
            //}
            
            return currentString;

        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

          //  string[] token = { "Wayne Rooney, 1985, Blue, Brown, 175", " Emma Watson, 1990, Brown, Brown, 170", " Justin Bieber, 1994, Hazel, Brown, 170", " Megan Fox, 1986, Blue, Black, 163", "Selena Gomez, 1992, Brown, Brown, 165 ", "Dimitar Berbatov, 1981, Blue, Black, 188", "Robyn Fenty, 1988, Green, Blond, 173", "Justin Timblake, 1981, Blue, Brown, 182" };


            //string[,] wordMatrix = new string[n, 6];
            string[][] wordMatrix = new string[6][];
            for (int index = 0; index < 6; index++)
            {
                wordMatrix[index] = new string[n];
            }

            for (int index = 0; index < n; index++)
            {
                string token = Console.ReadLine();
                string[] tokens = token.Split(',', ' ');
                int counter = 0;
                foreach (var item in tokens)
                {
                    if (item.Length > 0)
                    {
                       // wordMatrix[index, counter++] = item;
                        wordMatrix[counter][index] = item;
                        counter++;
                    }
                    
                }
            }

            //for (int index = 0; index < n; index++)
            //{
            //    string token = Console.ReadLine();
            //    string[] tokens = token.Split(',', ' ');
                
            //}

           // string[] e = new string[6];
         //   int iterator = 0;
            for (int colunds = 0; colunds < 6; colunds++)
            {
               // string[] a = new string[n];

               // a = wordMatrix[iterator];
             //   Buffer.BlockCopy(wordMatrix,
            //    iterator++;
                //for (int index = 0; index < n; index++)
                //{
                //    a[index] = wordMatrix[index, colunds];
                //}

              //  e[colunds] = mostCommonString(wordMatrix[colunds]);
                Console.WriteLine( mostCommonString(wordMatrix[colunds]));
            }
          //  Console.WriteLine("{0}\n{1}\n{2}\n{3}\n{4}\n{5}", e[0], e[1], e[2], e[3], e[4], e[5]);
           // Console.WriteLine(er);
            //Console.WriteLine( );
            
            //Console.WriteLine();
            //SortedDictionary<string,int> words = new SortedDictionary<string,int>();
            //words["ivan4o"] = 5;
            //words["joro"] = 8;
            //words["Joro"] = 3;
            //words["jorir"] = 3;
            //words["asi"] = 233;
            //words["asii"] = 23;
            //words["A"] = 0;
            //int cou = 0;
            //foreach (var item in wordMatrix)
            //{
            //    if (cou == 6)
            //    {
            //        Console.WriteLine();
            //        cou = 0;
            //    }
            //    Console.Write(item + " ");
            //    cou++;
            //}
            //Console.WriteLine();
            //Console.WriteLine();
            //foreach (var item in words)
            //{
            //    Console.WriteLine("{0}:{1}", item.Key,item.Value);
            //}
            //string[] a = { "ty", "ee", "ee","dsf", "we","dsf" ,"we", "ee", "sdfsdf", "dsf","dsf","ty","ty","sd","ty","ee","ee","dsf" };
          //  int e;
       //     string[] a = { "Rooney", "Watson", "Bieber", "Fox", "Gomez", "Berbatov", "Fenty", "Timblake" };
   //         Console.WriteLine(mostCommonString(a));
          //  Console.WriteLine(e);

    
     }
    }
}
